<?php 
namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

class CrowdFundingModel extends Model
{
    const STATUS_ACTIVE = 1;
    const STATUS_DELETE = 0;

    protected $connection = 'db_main';
    protected $isSharding = 1;
    protected $table = 'wp_sdk_crowd_funding';

    // protected $fillable = ['appid', 'item_key', 'item_value', 'status', 'create_time', 'modify_time'];

    public $timestamps = false;


    /**
     * 删除一个奖品详情
     */
    public static function delRecordByPrizeId($appid, $lotIds) {
        if(!$appid || !$lotIds) return false;
        $data = array(
            'status'       => self::STATUS_DELETE,
            'modify_time'  => time()
        );
        $map['appid'] = $appid;
        $map['dtype'] = 'crowd';
        $map['status'] = self::STATUS_ACTIVE;
        if (!is_array($lotIds)) {
            $lotIds = array($lotIds);
        }
        $map['dkey'] = array('IN', $lotIds);
        self::where($map)->save($data);
    }
}